//
//  TaskLogDetailViewController.m
//  OAProject
//
//  Created by yhj on 2017/4/21.
//  Copyright © 2017年 cdnunion. All rights reserved.
//  任务日志详情主界面

#import "TaskLogDetailViewController.h"

@interface TaskLogDetailViewController ()

@property(nonatomic,strong)UIView *mainView;

@end

@implementation TaskLogDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title=@"日志详情";

    [self.view addSubview:self.mainView];

}

-(UIView *)mainView
{
    if (!_mainView) {
        _mainView=[[UIView alloc]initWithFrame:CGRectMake(0,0,APPW,0)];
        _mainView.backgroundColor=WhiteColor;
        setViewHeight_Add(_mainView,kmargin*2+64);

        ZZCircleProgress *circleProgress=[[ZZCircleProgress alloc]initWithFrame:CGRectMake(kmargin*2,self.mainView.frame.size.height,kmargin*5,kmargin*5)];
        circleProgress.progress=self.model.tempo/100;
        circleProgress.showPoint=NO;
        circleProgress.animationModel=CircleIncreaseSameTime;
        ViewBorderRadius(circleProgress,kmargin*2,1,ClearColor);
        [self.mainView addSubview:circleProgress];

        UILabel *actionLabel=[self.mainView getLabelWithText:[NSString stringWithFormat:@"%@%@",self.model.user_name,self.model.action_show] font:Font_Number(16) textColor:DarkGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        [self.mainView addSubview:actionLabel];
        actionLabel.frame=CGRectMake(CGRectGetMaxX(circleProgress.frame)+kmargin,self.mainView.frame.size.height,APPW-kmargin*10,kmargin*3);
        setViewHeight_Add(_mainView,kmargin*3);

        if (self.model.memo.length>0)
        {
            // 任务日志记录
            NSString *taskLogStr=self.model.memo;
            CGFloat taskLogH=[Util GetHeightWithText:taskLogStr width:APPW-kmargin*10 limitHeight:MAXFLOAT font:16];
            UILabel *taskGoalDetailLabel=[self.mainView getLabelWithText:taskLogStr font:Font_Number(16) textColor:LightGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:0];
            [self.mainView addSubview:taskGoalDetailLabel];
            taskGoalDetailLabel.frame=CGRectMake(CGRectGetMaxX(circleProgress.frame)+kmargin,CGRectGetMaxY(actionLabel.frame),APPW-kmargin*10,taskLogH);
            setViewHeight_Add(_mainView,taskLogH+kmargin);
        }

        // 创建时间
        UILabel *timeLabel=[self.mainView getLabelWithText:[NSString stringWithFormat:@"%@",self.model.in_time] font:Font_Number(16) textColor:LightGreyColor textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        [self.mainView addSubview:timeLabel];
        [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-kmargin*2);
            make.top.mas_equalTo(self.mainView.frame.size.height);
        }];
        setViewHeight_Add(_mainView,kmargin*3);
    }
    return _mainView;
}


@end
